/**
 * Created by kinfen on 2016/12/15.
 */

var obj = {
    fileSize:(size) => {
        let K = 1000;
        if (size < K) return Math.round(size * 10) / 10 + "B";
        else if (size < Math.pow(K, 2)) return Math.round((size / Math.pow(K, 1)) * 10) / 10 + "K";
        else if (size < Math.pow(K, 3)) return Math.round((size / Math.pow(K, 2)) * 10) / 10 + "M";
        else return Math.round((size / Math.pow(K, 3)) * 10) / 10 + "G";
    }
}

module.exports = exports = obj;